home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgramD2.iso
/
Borland
/
Borland C++ For TASM
/
USRGUIDE.PAK
/
FINDCHAR.ASM
< prev
next >
Wrap
Assembly Source File
|
1996-02-21
|
1KB
|
30 lines
; Turbo Assembler example. Copyright (c) 1993 By Borland International, Inc.
; FINDCHAR.ASM - Searching for the last character of
; a null terminated string
; From the Turbo Assembler User's Guide, Ch. 18
.MODEL small
.CODE
PUBLIC _FindLastChar
_FindLastChar PROC
ARG StringToScan:WORD
push bp
mov bp,sp
cld ;we need string instructions to count up
mov ax,ds
mov es,ax ;set ES to point to the near data segment
mov di, [StringToScan] ;point ES:DI to start of
;passed string
mov al,0 ;search for the null that ends the string
mov cx,0ffffh ;search up to 64K-1 bytes
repnz scasb ;look for the null
dec di ;point back to the null
dec di ;point back to the last character
mov ax,di ;return the near pointer in AX
pop bp
ret
_FindLastChar ENDP
END